//
//  CAAddBank2View.m
//  LNH
//
//  Created by twentylx on 2018/2/8.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAAddBank2View.h"

@implementation CAAddBank2View

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.bankView];
    [self.bankView addSubview:self.bankLabel];
    [self.bankView addSubview:self.moreImageView];
    [self addSubview:self.lineView];
    [self addSubview:self.bankLocalTextField];
    [self addSubview:self.line1View];
    [self addSubview:self.saveButton];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_bankView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self).offset(10);
        make.height.mas_equalTo(44);
    }];
    
    [_bankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bankView).offset(20);
        make.centerY.equalTo(self.bankView);
    }];
    
    [_moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bankView).offset(-20);
        make.centerY.equalTo(self.bankView);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self.bankView);
        make.top.equalTo(self.bankView.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_bankLocalTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.lineView.mas_bottom);
        make.height.mas_equalTo(44);
    }];
    
    [_line1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.bankLocalTextField.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_saveButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.bottom.equalTo(self);
        make.height.mas_equalTo(44);
    }];
    
}

#pragma mark get & set
- (UIView *)bankView {
    if (!_bankView) {
        _bankView = [UIView new];
    }
    return _bankView;
}

- (UILabel *)bankLabel {
    if (!_bankLabel) {
        _bankLabel = [UILabel new];
        _bankLabel.text = @"选择银行";
        _bankLabel.font = [UIFont systemFontOfSize:16];
    }
    return _bankLabel;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = RGBCOLOR(189, 189, 189);
    }
    return _lineView;
}

- (UIImageView *)moreImageView {
    if (!_moreImageView) {
        _moreImageView = [UIImageView new];
        _moreImageView.image = LMImageNamed(@"more");
    }
    return _moreImageView;
}

- (UITextField *)bankLocalTextField {
    if (!_bankLocalTextField) {
        _bankLocalTextField = [UITextField new];
        _bankLocalTextField.placeholder = @"开户行";
        _bankLocalTextField.font = [UIFont systemFontOfSize:16];
        
        UIView *leftView = [[UIView alloc] initWithFrame:(CGRect){0, 0, 20, 20}];
        _bankLocalTextField.leftView = leftView;
        _bankLocalTextField.leftViewMode = UITextFieldViewModeAlways;
    }
    return _bankLocalTextField;
}

- (UIView *)line1View {
    if (!_line1View) {
        _line1View = [UIView new];
        _line1View.backgroundColor = RGBCOLOR(189, 189, 189);
    }
    return _line1View;
}

- (UIButton *)saveButton {
    if (!_saveButton) {
        _saveButton = [UIButton new];
        [_saveButton setTitle:@"保   存" forState:UIControlStateNormal];
        [_saveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _saveButton.titleLabel.font = [UIFont systemFontOfSize:24];
        _saveButton.backgroundColor = RGBCOLOR(233, 85, 19);
    }
    return _saveButton;
}

@end
